import React, {Component} from 'react'
import {HashRouter, Switch, Route, Redirect} from 'react-router-dom'
import asyncComponent from '@/utils/asyncComponent.jsx'
const home = asyncComponent(() => import("@/pages/home/index"))
const article = asyncComponent(() => import("@/pages/article-detail/index.jsx"))
const HeaderL =  asyncComponent(() => import ('@/components/header/index.jsx'))
const FooterL =  asyncComponent(() => import ('@/components/footer/index.jsx'))

export default class RouteConfig extends Component {
  render () {
    return (
      <HashRouter>
        <Route component= {HeaderL}/>
        {/* 在Switch中的路由，匹配才显示 */}
        <Switch>
          <Route path="/home" component= {home}/>
          <Route path="/article" component= {article}/>
          {/* 无参数时，重定向到首页，加上exact代表当前路由path的路径采用精确匹配 */}
          <Redirect exact from='/' to='/home'/>
        </Switch>
        <Route component= {FooterL}/>
        
      </HashRouter>
    )
  }
}